package com.ll.xiaonew.system.modules.promote.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ll.xiaonew.system.common.utils.PageUtils;
import com.ll.xiaonew.system.common.utils.Query;
import com.ll.xiaonew.system.modules.promote.dao.HomePrompteDao;
import com.ll.xiaonew.system.modules.promote.entity.HomePromoteBean;
import com.ll.xiaonew.system.modules.promote.service.HomePromoteService;
import org.springframework.stereotype.Service;

import java.util.Map;


@Service("homePromoteService")
public class HomePromoteServiceImpl extends ServiceImpl<HomePrompteDao, HomePromoteBean> implements HomePromoteService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<HomePromoteBean> page = this.page(
                new Query<HomePromoteBean>().getPage(params),
                new QueryWrapper<HomePromoteBean>()
        );

        return new PageUtils(page);
    }

    @Override
    public HomePromoteBean findCurrentDay() {
        HomePromoteBean currentDay = baseMapper.findCurrentDay();
        if (currentDay==null) {
            currentDay =  baseMapper.findCurrentLastDay();
        }
        return currentDay;
    }

}